package jsu.blogger.pojo;
import lombok.Data;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@Data
public class Post {
    private Long postId;  // 帖子的唯一标识
    private Long userId;  // 发布帖子的用户ID
    private String title;  // 帖子标题
    private String content="";  // 帖子内容
    private Integer postType;  // 帖子类型，0表示博客，1表示动态
    private Timestamp createdAt;  // 创建时间
    private Timestamp updatedAt;  // 更新时间
    private Integer likesCount = 0;  // 点赞数
    private Integer commentsCount = 0;  // 评论数
    private List<String> tags;  // 标签列表

    public Post() {
        this.tags = new ArrayList<>();  // 初始化标签列表
    }

    public Post(Long postId, Long userId, String title, String content, Integer postType,
                Timestamp createdAt, Timestamp updatedAt, Integer likesCount,
                Integer commentsCount, List<String> tags) {
        this.postId = postId;
        this.userId = userId;
        this.title = title;
        this.content = content;
        this.postType = postType;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.likesCount = likesCount;
        this.commentsCount = commentsCount;
        this.tags = tags != null ? tags : new ArrayList<>();  // 确保标签列表不为null
    }

    @Override
    public String toString() {
        return "帖子详情 {" +
                "帖子ID: " + postId +
                ", 用户ID: " + userId +
                ", 标题: '" + title + '\'' +
                ", 内容: '" + content + '\'' +
                ", 帖子类型: " + (postType!=null &&postType == 0  ? "博客" : "动态") +
                ", 创建时间: " + createdAt +
                ", 更新时间: " + updatedAt +
                ", 点赞数: " + likesCount +
                ", 评论数: " + commentsCount +
                ", 标签: " + tags +
                '}';
    }
}
